/**
 * 定义字段分为table信息定义,和html信息定义.前面有下划线_的字段是table信息定义, 不然是html信息定义
 * table信息定义和代码,业务有关. html信息定义表示完整的html信息, 和代码无关, 他能映射一段html代码
 *
 * html信息定义遵从标签属性就以标签名为可以, 字符串为value放入attribute里, children放入children, _tag标明是啥标签,
 * 其中tg,
 * @type {{modelAttribute: {head: {td: {children: [{style: string, tag: string, title: string, class: string, value: string, events: [{name: string, params: string, fun: string}]}], attribute: {style: string}}}}, model: string, id: string, class: string}}
 */
let tableDefinition = {
    _table: {
        "id": "myTable",
        "class": "table table-striped table-bordered table-condensed",
    },
    _model: "prefixButton",//prefixButton,readonly,
    _modelAttribute: {
        _body: {
            _td: {
                attribute: {
                    style: "width: 1%;border: none",
                },
                children: [
                    {
                        tag: "input",
                        attribute: {
                            name: "prdha",
                            type: "hidden",
                            _value: "prdha",
                            _valueType: "columnValue",
                        }
                    },
                    {
                        tag: "input",
                        attribute: {
                            name: "prdha",
                            type: "hidden",
                            _value: "nhlx",
                            _valueType: "columnValue",
                        }
                    },
                    {
                        tag: "button",
                        attribute: {
                            class: "btn-primary btn-mini",
                            title: "删除本行",
                            events: [
                                {
                                    name: "onclick",
                                    fun: "deleteTr",
                                    params: "this,'3000000003'",
                                }
                            ],
                        },
                        children: [
                            {
                                tag: "_text",
                                text: "删除"
                            }
                        ]
                    }
                ]
            },
            attribute:{
                id:"bomMaterialBody"
            }
        },
        _head: {//head是table信息定义
            _td: {//td是table信息定义
                //td内部就是html信息定义,
                attribute: {
                    style: "width: 1%;border: none;"
                },
                children: [
                    {
                        tag: "button",
                        attribute: {
                            class: "btn-primary btn-mini",
                            title: "增加一行",
                            events: [
                                {
                                    name: "onclick",
                                    fun: "appendTr",
                                    params: "'bomMaterialBody'",
                                }
                            ],
                        },
                        children: [
                            {
                                tag: "_text",
                                text: "增加"

                            }
                        ]
                    }]
            }
        }
    }
};
let columnsDefinition = [
    {
        _showType: "index",
        _title: '序号',
        _headClass: "bgcolorth",
        _bodyClass: "bgcolorth",
        _index: 0,
        _show: true,
        attribute: {
            style: "padding: 0;margin: 0;border:none;text-align: center;width: 5%;",
        }
    },
    {
        _showType: "renderAll",
        _renderFunction: "renderCode",
        _title: '组件编码',
        _index: 1,
    },
    {
        _title: '组件名称',
        _headClass: "bgcolorth",
        _bodyClass: "bgcolorth",
        _column: "maktx",
        _index: 2,
        _show: true,
        _type: "input",
        _inputAttribute: {
            name:"maktx",
            readonly: "readonly"
        },
        attribute: {
            style: "width: 15%;padding: 0;margin: 0;border:none;"
        }
    },
    {
        _title: '数量',
        _bodyClass: "bgcolorth",
        _column: 'menge',
        _bodyClass: "bgcolorth",
        _index: 3,
        _show: true,
        _type: "input",
        _inputAttribute: {
            placeholder: "请输入",
            events: [
                {
                    name: "onblur",
                    fun: "calPrice"
                }
            ],
            style: "padding: 0;margin: 0;text-align: center;border:none;width: 100%;"
        },
        attribute: {
            style: "width: 5%;"
        }
    }, {
        _title: '价格(元)',
        _bodyClass: "bgcolorth",
        _column: 'price',
        _defaultValue: 0.0,
        _bodyClass: "bgcolorth",
        _index: 4,
        _show: true,
        _type: "input",
        _inputAttribute: {
            placeholder: "请输入",
            events: [
                {
                    name: "onblur",
                    fun: "calPrice"
                }
            ],
            style: "padding: 0;margin: 0;text-align: center;border:none;width: 100%;"
        },
        attribute: {
            style: "width: 5%;"
        }
    }, {
        _title: '单位',
        _bodyClass: "bgcolorth",
        _column: 'meins',
        _bodyClass: "bgcolorth",
        _index: 5,
        _show: true,
        _type: "input",
        _inputAttribute: {
            placeholder: "请输入",
            events: [
                {
                    name: "onblur",
                    fun: "calPrice"
                }
            ],
            style: "padding: 0;margin: 0;text-align: center;border:none;width: 100%;"
        },
        attribute: {
            style: "width: 5%;"
        }
    }, {
        _title: '封样供方',
        _bodyClass: "bgcolorth",
        _column: 'supplier',
        _bodyClass: "bgcolorth",
        _index: 6,
        _show: true,
        _type: "input",
        _inputAttribute: {
            placeholder: "双击选择供应商",
            style: "padding: 0;margin: 0;text-align: center;border:none;width: 100%;"
        },
        attribute: {
            style: "width: 12%;",
            events: [
                {
                    name: "ondblclick",
                    fun: "getSupp",
                    params: "this"
                }
            ],
        }
    }, {
        _title: '类型',
        _bodyClass: "bgcolorth",
        _column: 'category',
        _bodyClass: "bgcolorth",
        _index: 7,
        _show: true,
        _type: "input",
        _inputAttribute: {
            style: "padding: 0;margin: 0;border:none;text-align: center;width: 100%;"
        },
        attribute: {
            style: "width: 5%;"
        }
    }, {
        _title: '备注',
        _bodyClass: "bgcolorth",
        _column: 'potx',
        _bodyClass: "bgcolorth",
        _index: 8,
        _show: true,
        _type: "input",
        _inputAttribute: {
            style: "padding: 0;margin: 0;border:none;text-align: center;width: 100%;"
        },
        attribute: {
            style: "width: 8%;"
        }
    }, {
        _title: '损耗率',
        _bodyClass: "bgcolorth",
        _column: 'wastageRate',
        _bodyClass: "bgcolorth",
        _index: 8,
        _show: true,
        _type: "input",
        _inputAttribute: {
            style: "padding: 0;margin: 0;border:none;text-align: center;width: 100%;"
        },
        attribute: {
            style: "width: 5%;"
        }
    },
    {
        _showType: "renderAll",
        _renderFunction: "renderStatus",
        _title: '状态',
        _index: 9,
    },
]
